<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>日语学习助手 - 句型与例句</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
            background: linear-gradient(135deg, #f5f7fa 0%, #e4efe9 100%);
            color: #333;
            padding: 20px;
            min-height: 100vh;
        }
        .container {
            max-width: 1000px;
            margin: 0 auto;
            background: white;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }
        header {
            background: linear-gradient(135deg, #3498db 0%, #2c3e50 100%);
            color: white;
            padding: 25px;
            text-align: center;
        }
        h1 {
            font-size: 2.2rem;
            margin-bottom: 10px;
        }
        .subtitle {
            font-size: 1rem;
            opacity: 0.9;
        }
        .content {
            padding: 25px;
        }
        .section {
            margin-bottom: 40px;
            padding: 20px;
            border-radius: 10px;
            background: #f8f9fa;
        }
        .section-title {
            font-size: 1.8rem;
            color: #2c3e50;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid #3498db;
            text-align: center;
        }
        .pattern-container, .example-container {
            margin-bottom: 30px;
        }
        .pattern-line, .example-line {
            display: flex;
            flex-wrap: wrap;
            margin-bottom: 20px;
            padding: 15px;
            border-radius: 10px;
            background: white;
            transition: all 0.3s ease;
            border-left: 4px solid #3498db;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
        }
        .pattern-line:hover, .example-line:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }
        .japanese {
            flex: 1;
            min-width: 300px;
            font-size: 1.3rem;
            font-weight: bold;
            margin-bottom: 10px;
        }
        .romaji {
            flex: 1;
            min-width: 300px;
            padding: 0 15px;
            color: #7d3c98;
            font-style: italic;
            margin-bottom: 10px;
            border-left: 1px dashed #ddd;
        }
        .chinese {
            flex: 1;
            min-width: 300px;
            padding-left: 15px;
            color: #2c3e50;
            margin-bottom: 10px;
            border-left: 1px dashed #ddd;
        }
        .pronunciation-btn {
            background: linear-gradient(to bottom, #3498db, #2980b9);
            color: white;
            border: none;
            border-radius: 25px;
            padding: 10px 20px;
            cursor: pointer;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 10px auto 0;
            width: 100%;
            max-width: 200px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
        .pronunciation-btn:hover {
            background: linear-gradient(to bottom, #2980b9, #3498db);
            box-shadow: 0 6px 12px rgba(0,0,0,0.15);
            transform: translateY(-2px);
        }
        .btn-icon {
            margin-right: 8px;
        }
        .vocabulary-section {
            background: #e8f4fc;
            padding: 25px;
            border-radius: 10px;
            margin-top: 40px;
        }
        .vocabulary-title {
            font-weight: bold;
            color: #2c3e50;
            margin-bottom: 20px;
            font-size: 1.5rem;
            text-align: center;
            padding-bottom: 10px;
            border-bottom: 2px solid #3498db;
        }
        .vocabulary-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }
        .vocabulary-card {
            background: white;
            padding: 15px;
            border-radius: 10px;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
            transition: transform 0.3s;
        }
        .vocabulary-card:hover {
            transform: translateY(-5px);
        }
        .word {
            font-weight: bold;
            font-size: 1.2rem;
            margin-bottom: 5px;
        }
        .word-romaji {
            color: #7d3c98;
            font-style: italic;
            margin-bottom: 5px;
        }
        .word-meaning {
            color: #2c3e50;
            margin-bottom: 10px;
        }
        .word-pronunciation-btn {
            background: linear-gradient(to bottom, #e67e22, #d35400);
            color: white;
            border: none;
            border-radius: 20px;
            padding: 8px 15px;
            cursor: pointer;
            transition: all 0.3s;
            width: 100%;
            font-size: 0.9rem;
        }
        .word-pronunciation-btn:hover {
            background: linear-gradient(to bottom, #d35400, #e67e22);
            transform: translateY(-2px);
        }
        .footer {
            text-align: center;
            padding: 20px;
            color: #7f8c8d;
            font-size: 0.9rem;
            border-top: 1px solid #eee;
        }
        /* 移动设备优化 */
        @media (max-width: 768px) {
            .pattern-line, .example-line {
                flex-direction: column;
            }
            .romaji, .chinese {
                padding: 10px 0;
                border-left: none;
                border-top: 1px dashed #ddd;
            }
            .japanese, .romaji, .chinese {
                min-width: 100%;
            }
            .pronunciation-btn {
                margin-top: 15px;
            }
            .vocabulary-grid {
                grid-template-columns: 1fr;
            }
        }
        /* 语音状态提示 */
        .speech-status {
            text-align: center;
            margin-top: 10px;
            font-size: 0.9rem;
            color: #7f8c8d;
            height: 20px;
        }
        .example-dialog {
            margin-left: 20px;
            color: #555;
            font-style: italic;
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>日语学习助手 - 句型与例句</h1>
            <p class="subtitle">点击发音按钮可听到慢速日语发音</p>
        </header>
        
        <div class="content">
            <div class="section">
                <h2 class="section-title">文型 (句型)</h2>
                
                <div class="pattern-container">
                    <div class="pattern-line">
                        <div class="japanese">1. わたしは マイク・ミラーです。</div>
                        <div class="romaji">Watashi wa Maiku Mirā desu.</div>
                        <div class="chinese">1. 我是迈克·米勒。</div>
                        <button class="pronunciation-btn" onclick="speak('わたしはマイク・ミラーです', 'pattern1')">
                            <span class="btn-icon">🔊</span> 发音
                        </button>
                        <div class="speech-status" id="pattern1-status"></div>
                    </div>
                    
                    <div class="pattern-line">
                        <div class="japanese">2. サントスさんは 学生じゃ ありません。（では）</div>
                        <div class="romaji">Santosu-san wa gakusei ja arimasen. (dewa)</div>
                        <div class="chinese">2. 桑托斯先生不是学生。</div>
                        <button class="pronunciation-btn" onclick="speak('サントスさんは学生じゃありません', 'pattern2')">
                            <span class="btn-icon">🔊</span> 发音
                        </button>
                        <div class="speech-status" id="pattern2-status"></div>
                    </div>
                    
                    <div class="pattern-line">
                        <div class="japanese">3. ミラーさんは 会社員ですか。</div>
                        <div class="romaji">Mirā-san wa kaishain desu ka.</div>
                        <div class="chinese">3. 米勒先生是公司职员吗？</div>
                        <button class="pronunciation-btn" onclick="speak('ミラーさんは会社員ですか', 'pattern3')">
                            <span class="btn-icon">🔊</span> 发音
                        </button>
                        <div class="speech-status" id="pattern3-status"></div>
                    </div>
                    
                    <div class="pattern-line">
                        <div class="japanese">4. サントスさんも 会社員です。</div>
                        <div class="romaji">Santosu-san mo kaishain desu.</div>
                        <div class="chinese">4. 桑托斯先生也是公司职员。</div>
                        <button class="pronunciation-btn" onclick="speak('サントスさんも会社員です', 'pattern4')">
                            <span class="btn-icon">🔊</span> 发音
                        </button>
                        <div class="speech-status" id="pattern4-status"></div>
                    </div>
                </div>
                
                <h2 class="section-title">例文 (例句)</h2>
                
                <div class="example-container">
                    <div class="example-line">
                        <div class="japanese">1. [あなたは] マイク・ミラーさんですか。<br>
                            <span class="example-dialog">……はい、[わたしは] マイク・ミラーです。</span>
                        </div>
                        <div class="romaji">[Anata wa] Maiku Mirā-san desu ka.<br>
                            <span class="example-dialog">......Hai, [watashi wa] Maiku Mirā desu.</span>
                        </div>
                        <div class="chinese">1. 你是迈克·米勒先生吗？<br>
                            <span class="example-dialog">……是的，我是迈克·米勒。</span>
                        </div>
                        <button class="pronunciation-btn" onclick="speak('あなたはマイク・ミラーさんですか。はい、わたしはマイク・ミラーです', 'example1')">
                            <span class="btn-icon">🔊</span> 发音
                        </button>
                        <div class="speech-status" id="example1-status"></div>
                    </div>
                    
                    <div class="example-line">
                        <div class="japanese">2. ミラーさんは 学生ですか。<br>
                            <span class="example-dialog">……いいえ、[わたしは] 学生じゃ ありません。</span>
                        </div>
                        <div class="romaji">Mirā-san wa gakusei desu ka.<br>
                            <span class="example-dialog">......Iie, [watashi wa] gakusei ja arimasen.</span>
                        </div>
                        <div class="chinese">2. 米勒先生是学生吗？<br>
                            <span class="example-dialog">……不，我不是学生。</span>
                        </div>
                        <button class="pronunciation-btn" onclick="speak('ミラーさんは学生ですか。いいえ、わたしは学生じゃありません', 'example2')">
                            <span class="btn-icon">🔊</span> 发音
                        </button>
                        <div class="speech-status" id="example2-status"></div>
                    </div>
                    
                    <div class="example-line">
                        <div class="japanese">3. ワンさんは 銀行員ですか。<br>
                            <span class="example-dialog">……いいえ、[ワンさんは] 銀行員じゃ ありません。医者です。</span>
                        </div>
                        <div class="romaji">Wan-san wa ginkōin desu ka.<br>
                            <span class="example-dialog">......Iie, [Wan-san wa] ginkōin ja arimasen. Isha desu.</span>
                        </div>
                        <div class="chinese">3. 王先生是银行职员吗？<br>
                            <span class="example-dialog">……不，王先生不是银行职员。是医生。</span>
                        </div>
                        <button class="pronunciation-btn" onclick="speak('ワンさんは銀行員ですか。いいえ、ワンさんは銀行員じゃありません。医者です', 'example3')">
                            <span class="btn-icon">🔊</span> 发音
                        </button>
                        <div class="speech-status" id="example3-status"></div>
                    </div>
                    
                    <div class="example-line">
                        <div class="japanese">4. あの 方は どなたですか。<br>
                            <span class="example-dialog">……ワットさんです。さくら大学の 先生です。</span>
                        </div>
                        <div class="romaji">Ano kata wa donata desu ka.<br>
                            <span class="example-dialog">......Watto-san desu. Sakura daigaku no sensei desu.</span>
                        </div>
                        <div class="chinese">4. 那位是谁？<br>
                            <span class="example-dialog">……是瓦特先生。是樱花大学的老师。</span>
                        </div>
                        <button class="pronunciation-btn" onclick="speak('あの方はどなたですか。ワットさんです。さくら大学の先生です', 'example4')">
                            <span class="btn-icon">🔊</span> 发音
                        </button>
                        <div class="speech-status" id="example4-status"></div>
                    </div>
                    
                    <div class="example-line">
                        <div class="japanese">5. グプタさんは 会社員ですか。<br>
                            <span class="example-dialog">……はい、会社員です。カリナさんも 会社員ですか。<br>
                            ……いいえ。[カリナさんは] 学生です。</span>
                        </div>
                        <div class="romaji">Guputa-san wa kaishain desu ka.<br>
                            <span class="example-dialog">......Hai, kaishain desu. Karina-san mo kaishain desu ka.<br>
                            ......Iie. [Karina-san wa] gakusei desu.</span>
                        </div>
                        <div class="chinese">5. 古普塔先生是公司职员吗？<br>
                            <span class="example-dialog">……是的，是公司职员。卡丽娜女士也是公司职员吗？<br>
                            ……不，卡丽娜女士是学生。</span>
                        </div>
                        <button class="pronunciation-btn" onclick="speak('グプタさんは会社員ですか。はい、会社員です。カリナさんも会社員ですか。いいえ、カリナさんは学生です', 'example5')">
                            <span class="btn-icon">🔊</span> 发音
                        </button>
                        <div class="speech-status" id="example5-status"></div>
                    </div>
                    
                    <div class="example-line">
                        <div class="japanese">6. テレーザちゃんは 何歳ですか。<br>
                            <span class="example-dialog">……9歳です。</span>
                        </div>
                        <div class="romaji">Terē-chan wa nansai desu ka.<br>
                            <span class="example-dialog">......Kyūsai desu.</span>
                        </div>
                        <div class="chinese">6. 特蕾莎小朋友几岁了？<br>
                            <span class="example-dialog">……9岁。</span>
                        </div>
                        <button class="pronunciation-btn" onclick="speak('テレーザちゃんは何歳ですか。9歳です', 'example6')">
                            <span class="btn-icon">🔊</span> 发音
                        </button>
                        <div class="speech-status" id="example6-status"></div>
                    </div>
                </div>
            </div>
            
            <div class="vocabulary-section">
                <div class="vocabulary-title">单词汇总</div>
                <div class="vocabulary-grid">
                    <div class="vocabulary-card">
                        <div class="word">わたし</div>
                        <div class="word-romaji">watashi</div>
                        <div class="word-meaning">我</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('わたし', 'word1')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word1-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">学生</div>
                        <div class="word-romaji">gakusei</div>
                        <div class="word-meaning">学生</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('学生', 'word2')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word2-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">会社員</div>
                        <div class="word-romaji">kaishain</div>
                        <div class="word-meaning">公司职员</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('会社員', 'word3')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word3-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">銀行員</div>
                        <div class="word-romaji">ginkōin</div>
                        <div class="word-meaning">银行职员</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('銀行員', 'word4')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word4-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">医者</div>
                        <div class="word-romaji">isha</div>
                        <div class="word-meaning">医生</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('医者', 'word5')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word5-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">先生</div>
                        <div class="word-romaji">sensei</div>
                        <div class="word-meaning">老师</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('先生', 'word6')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word6-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">大学</div>
                        <div class="word-romaji">daigaku</div>
                        <div class="word-meaning">大学</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('大学', 'word7')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word7-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">何歳</div>
                        <div class="word-romaji">nansai</div>
                        <div class="word-meaning">几岁</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('何歳', 'word8')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word8-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">はい</div>
                        <div class="word-romaji">hai</div>
                        <div class="word-meaning">是</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('はい', 'word9')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word9-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">いいえ</div>
                        <div class="word-romaji">iie</div>
                        <div class="word-meaning">不</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('いいえ', 'word10')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word10-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">も</div>
                        <div class="word-romaji">mo</div>
                        <div class="word-meaning">也</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('も', 'word11')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word11-status"></div>
                    </div>
                    
                    <div class="vocabulary-card">
                        <div class="word">方</div>
                        <div class="word-romaji">kata</div>
                        <div class="word-meaning">人 (敬语)</div>
                        <button class="word-pronunciation-btn" onclick="speakWord('方', 'word12')">
                            🔊 发音
                        </button>
                        <div class="speech-status" id="word12-status"></div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="footer">
            <p>日语学习助手 &copy; 2023 - 让日语学习更轻松</p>
        </div>
    </div>

    <script>
        // 解决移动设备上语音合成需要用户交互的问题
        let speechSynthesisAllowed = false;
        
        // 在用户与页面交互后启用语音合成
        document.addEventListener('click', function() {
            speechSynthesisAllowed = true;
        }, { once: true });
        
        function speak(text, elementId) {
            if (!speechSynthesisAllowed) {
                alert('请先点击页面任意位置激活语音功能');
                return;
            }
            
            if ('speechSynthesis' in window) {
                // 停止任何当前正在播放的语音
                window.speechSynthesis.cancel();
                
                const utterance = new SpeechSynthesisUtterance(text);
                utterance.lang = 'ja-JP';
                utterance.rate = 0.7; // 设置慢速发音
                utterance.pitch = 1.0;
                utterance.volume = 1;
                
                // 显示语音状态
                const statusElement = document.getElementById(elementId + '-status');
                if (statusElement) {
                    statusElement.textContent = '发音中...';
                    
                    utterance.onend = function() {
                        statusElement.textContent = '';
                    };
                    
                    utterance.onerror = function() {
                        statusElement.textContent = '发音出错';
                    };
                }
                
                speechSynthesis.speak(utterance);
            } else {
                alert('抱歉，您的浏览器不支持语音合成功能。请尝试使用Chrome、Edge或Safari浏览器。');
            }
        }
        
        function speakWord(word, elementId) {
            if (!speechSynthesisAllowed) {
                alert('请先点击页面任意位置激活语音功能');
                return;
            }
            
            if ('speechSynthesis' in window) {
                // 停止任何当前正在播放的语音
                window.speechSynthesis.cancel();
                
                const utterance = new SpeechSynthesisUtterance(word);
                utterance.lang = 'ja-JP';
                utterance.rate = 0.8; // 设置稍慢速发音
                utterance.pitch = 1.0;
                utterance.volume = 1;
                
                // 显示语音状态
                const statusElement = document.getElementById(elementId + '-status');
                if (statusElement) {
                    statusElement.textContent = '发音中...';
                    
                    utterance.onend = function() {
                        statusElement.textContent = '';
                    };
                    
                    utterance.onerror = function() {
                        statusElement.textContent = '发音出错';
                    };
                }
                
                speechSynthesis.speak(utterance);
            } else {
                alert('抱歉，您的浏览器不支持语音合成功能。请尝试使用Chrome、Edge或Safari浏览器。');
            }
        }
    </script>
</body>
</html>